package com.xxx.service.config;

import com.xxx.service.filter.JwtAuthenticationFilter;
import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.Ordered;

@Configuration
public class FilterConfig {

    @Bean
    public FilterRegistrationBean<JwtAuthenticationFilter> jwtFilterRegistration(
            JwtAuthenticationFilter jwtFilter) {

        FilterRegistrationBean<JwtAuthenticationFilter> registration =
                new FilterRegistrationBean<>(jwtFilter);

        registration.setOrder(Ordered.HIGHEST_PRECEDENCE); // 最高优先级
//        registration.addUrlPatterns("/api/user/*", "/api/admin/*");
        registration.addUrlPatterns("/api/*");

        return registration;
    }
}